package com.study.www.demofilter.config;

import com.study.www.demo.Application;
import lombok.extern.slf4j.Slf4j;
import org.joda.time.DateTime;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;

import javax.servlet.annotation.WebInitParam;
import javax.servlet.annotation.WebServlet;

/**
 * @author zhuyanpeng
 * @since 2019/12/30
 */
@Slf4j
@WebServlet(name = "demoDispatchServlet", urlPatterns = "*.demo")
public class DemoDispatcherServlet extends DispatcherServlet {


    public DemoDispatcherServlet(WebApplicationContext webApplicationContext) {
        super(webApplicationContext);
        log.warn("DemoDispatcherServlet 的 constructor ;启动时间=>" + new DateTime().toString(Application.DATEFORMAT));
    }

    @Override
    protected void initStrategies(ApplicationContext context) {
        this.getServletContext().setAttribute("ServletConfig",this.getServletConfig());
        log.warn("DemoDispatcherServlet 的 initStrategies ;启动时间=>" + new DateTime().toString(Application.DATEFORMAT));
        super.initStrategies(context);
    }


    @Override
    public void destroy() {
        super.destroy();
        log.warn("DemoDispatcherServlet 的 destroy ;启动时间=>" + new DateTime().toString(Application.DATEFORMAT));
    }
}